package com.ark.mapper;

import com.ark.dto.EmployeePageQueryDTO;
import com.ark.entity.Employee;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {

    /**
     * 根据用户名查询员工
     * @param username 用户名
     * @return 员工信息
     */
    @Select("SELECT * FROM employee WHERE username = #{username}")
    Employee getByUsername(String username);

    /**
     * 分页查询
     * @param employeePageQueryDTO 查询对象
     * @return 查询结果
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 根据id查询密码
     * @param empId 员工id
     * @return 密码
     */
    @Select("SELECT password FROM employee WHERE id=#{empId}")
    String getPassById(Long empId);

    @Update("UPDATE employee SET password=#{newPass} WHERE id=#{empId}")
    Integer updatePass(Long empId,String newPass);
}
